import React, { Component } from 'react'
// React的事件处理其实就是  小驼峰式的事件 = { 函数 }
// 同时也要注意 this 指向
export default class App extends Component {
  state = {
    count: 100
  }
  constructor (props) {
    super(props)
    // this.addFn = this.add.bind(this)
    this.add = this.add.bind(this)
  }

  add () {
    console.log(this)
  }
  render() {
    return (
      <div>
        {/* 利用es6的构造函数添加自定义的属性，改变this指向 */}
        {/* <button onClick = { this.addFn }>+</button> { this.state.count } */}
        <button onClick = { this.add }>+</button> { this.state.count }
      </div>
    )
  }
}
